package com.sy.mq.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/receive")
public class ReceiveController {

    @Resource
    private RabbitTemplate rabbitTemplate;

    @RequestMapping
    public void receive() {
        Object msg = rabbitTemplate.receiveAndConvert("myDirectQueue");
        System.out.println("拿到的队列的消息内容:------------>" + msg.toString());
    }
}
